package com.dao;

import com.bean.Entity;

import java.util.List;

/**
 * @author ${user}
 */
public interface Crud<T> {
    /**
     *
     * @param object - object to insert
     * @return newly saved object id
     */
    int insert(T object);


    /**
     *
     * @param objects - list of objects to insert using batch insert
     * @return the list of ids of newly saved objects
     */
    List<Integer> insert(List<T> objects);


    /**
     *
     * @param object - object to delete
     * @return true in case of success<br>false if delete fails
     */
    int delete(T object);

    /**
     *
     * @param objects - objects to delete
     * @return true in case of success<br>false if delete fails
     */
    int delete(List<T> objects);

    /**
     * removes all records
     * @return true in case of success<br>false if delete fails
     */
    boolean deleteAll();

    /**
     *
     * @param object - object which needs to be updated
     * @return true in case of success<br>false if update fails
     */
    boolean update(T object);


    /**
     *
     * @param id - id of object to be found
     * @return the searched object, null if there is no object with such id
     */
    T find(Integer id);


    /**
     *
     * @return the list of all objects
     */
    List<T> selectAll();
}
